@section('content')
<div class="am-cf am-padding">
   <div class="am-fl am-cf">
      <strong class="am-text-primary am-text-lg">订单列表</strong>
   </div>
</div>
<div class="am-g">
      <div class="am-u-md-12">
      	<form class="am-form-inline" role="form" style="text-align: right;">
		  <div class="am-form-group">
		    <input type="text" name="name" class="am-form-field" placeholder="用户名称">
		  </div>
		  <div class="am-form-group">
		    <input type="text" name="addressName" class="am-form-field" placeholder="收货人名称">
		  </div>
		  <div class="am-form-group">
		    <input type="text" name="addressTel" class="am-form-field" placeholder="收货人电话">
		  </div>
		  <button type="submit" class="am-btn am-btn-default">查询</button>
		</form>
      </div>
    </div>
<div class="am-g">
      <div class="am-u-sm-12">
          <table class="am-table am-table-striped am-table-hover table-main">
            <thead>
              <tr>
                <th>订单编号</th>
                <th>订单时间</th>
                <th>订单用户</th>
                <th>订单总价</th>
                <th>商品总价</th>
                <th>运费</th>
                <th>支付方式</th>
                <th>订单状态</th>
                <th>终端类型</th>
                <th>管理订单</th>
              </tr>
          </thead>
          <tbody>
          	@foreach ($orders as $o)
            <tr data-id="{{$o->id}}">
              <td>{{$o->id}}</td>
              <td>{{date("Y-m-d H:i",strtotime($o->created_at))}}</td>
              <td>{{$o->user_name}}</td>
              <td>{{$o->product_total_price + $o->freight}}</td>
              <td>{{$o->product_total_price}}</td>
              <td>{{$o->freight}}</td>
              <td>
              @if($o->pay_type == 1)
                                                            支付宝支付
              @elseif($o->pay_type == 2)
                                                              微信支付
              @elseif($o->pay_type == 3)
                                                              线下支付
              @endif
              </td>
              <td class="status">
              	@if($o->status == 0)
              		未支付
              	@elseif ($o->status == 1)
				             已支付
				@elseif ($o->status == 2)
				            已发货
				@elseif ($o->status == 3)
				            已退货
				@else
					系统回收
				@endif
              </td>
              <td>
              	@if($o->terminal_type == 1)
              		电脑端
              	@elseif ($o->terminal_type == 2)
				            手机端
				@else
					未知
				@endif
              </td>
              <td>
                <div class="am-btn-toolbar">
                  <div class="am-btn-group am-btn-group-xs">
                  	<a class="am-btn am-btn-default am-btn-xs am-text-secondary" href="{{URL::route('order.detail',$o->id)}}">
                  		<span class="am-icon-search" >查看</span></a>
                  	<!-- 
                  	<button class="am-btn am-btn-default am-btn-xs am-text-secondary order-returns" >
                  		<span class="am-icon-search"></span> 退货</button>
                  	 -->
                  </div>
                </div>
              </td>
            </tr>
            @endforeach
          </tbody>
        </table>
        <div class="am-cf">
		  <div class="am-fr">
		  	<!-- 分页列表 -->
		  	{{$orders->appends($search)->links("admin.slider")}}
		  </div>
		</div>
      </div>
    </div>
@stop

@section('script')

<script type="text/javascript">
$(function () {
	$(".order-returns").on("click",function(){
		 $btn = $(this);
		 $tr = $btn.closest("tr");
		 $btn.button("loading");
		 $.post("{{URL::route('order.returns')}}",$tr.data(),function(data){
			  $btn.button("reset");
	  		  if (data.success){
	  				$tr.find("td.status").text("已退货");
	  		  } 
		 });
	});
});
</script>
@stop
